import { createApp } from "vue";

// 完整引入 ElementPlus
// TODO: 后续上线时优化
import ElementPlus from "element-plus";
import zhCN from "element-plus/dist/locale/zh-cn.mjs";
import "element-plus/dist/index.css";

// 将 @element-plus/icons-vue 内所有具名导出的内容组装成一个对象 ElementPlusIconsVue
import * as ElementPlusIconsVue from "@element-plus/icons-vue";

import router from "./router";
import store from "./store";

import App from "@/App.vue";

import { has } from "@/directives/has";

// 创建应用实例
const app = createApp(App);

// 注册全局指令
app.directive("has", has);

// 注册插件
app
  .use(ElementPlus, {
    locale: zhCN,
  })
  .use(router)
  .use(store);

// 将 ElementPlusIconsVue 内的所有图标组件都全局注册上
for (const [key, component] of Object.entries(ElementPlusIconsVue)) {
  app.component(key, component);
}

// 挂载
app.mount("#app");
